﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VideoClubGorbea.Common.Interfaces;
using VideoClubGorbea.ServicesClient;


namespace VideoClubGorbea.Web.Controllers
{
    public class MovieController : AsyncController
    {
        public IMovieServicesProxy Factory { get; set; }


        public MovieController(IMovieServicesProxy movieFactory)
        {
            Factory = movieFactory;
        }

        public ActionResult GetMovieById(int? id)
        {
            var movieTask = Factory.GetMovieByIdAsync(id);
            movieTask.Start();
            var result = movieTask.Result;
            return Request.IsAjaxRequest() ?
     (ActionResult)PartialView("Movie_Partial", result) :
     (ActionResult)View("Movie", result);

        }

    }
}
